package com.zhiyou100.dao.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate5.HibernateTemplate;
import org.springframework.stereotype.Repository;

import com.zhiyou100.dao.TeacherDAO;
import com.zhiyou100.model.Teacher;

@Repository("teacherDAO")
public class TeacherDAOImpl implements TeacherDAO{
	
	@Autowired
	HibernateTemplate hibernateTemplate;
	
	public void add(Teacher e) {
		hibernateTemplate.save(e);
		
	}

	public void update(Teacher e) {
		// TODO Auto-generated method stub
		hibernateTemplate.update(e);
	}

	public void deleteById(int id) {
		// TODO Auto-generated method stub
		Teacher teacher = new Teacher();
		teacher.setId(id);
		hibernateTemplate.delete(teacher);
	}

	public List<Teacher> queryAll() {
		// TODO Auto-generated method stub
		return hibernateTemplate.loadAll(Teacher.class);
	}

	public Teacher queryById(int id) {
		// TODO Auto-generated method stub
		return hibernateTemplate.get(Teacher.class, id);
	}

}
